﻿using System.Collections;
using System.Linq;
using Rhizome.Contract;

namespace Rhizome.Model
{
    public static class EventSinkExtension
    {
        public static object GetForwardEvent(this IEnumerable items)
        {
            var events =
                from f in items.OfType<IForwardEvent>()
                let e = f.GetForwardEvent()
                where e != null
                select e;

            return events.FirstOrDefault();
        }
    }
}